<?php

Yii::import('application.models._base.BaseEnquary');

class Enquary extends BaseEnquary {

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public function rules() {
        return array(
            // array('poa_mage,poi_mage,person_image,signature', 'file', 'types' => 'jpg, gif, png'),enquiry_type
            array('category, coustmer_name, clint_name, alternate_no, resi_address, city, landmark,enquiry_type, zone, product_type, state, pin_code, los_no,activation_date', 'required'),
            array('users_id, applied_for_loan, taotal_family_mamber', 'numerical', 'integerOnly' => true),
            array('distance_from_branch', 'numerical'),
            array('category, coustmer_name, coustmer_id, clint_name, alternate_no, installation_address, city, 
                landmark, zone, product_type, state, los_no, plan_name, case_type, address_confirmation,
                subsriber_confirmation, av_result, av_code, applied_for_connection, name_of_person_meet,
                relationship, remarks, get_location, resident, income, organization, occupation, company, agri_land, vehicle, gate_colour, 
                wall_colour, person_image, poi_image, poa_image, signature, depandent, resident_detail', 'length', 'max' => 45),
            array('pin_code', 'length', 'max' => 10),
            array('earning_mamber, total_emp, net_sailry', 'length', 'max' => 20),
            array('neighbor, office_image, time_of_job', 'length', 'max' => 40),
            array('resi_address', 'length', 'max' => 100),
            array('address_confirmation, subsriber_confirmation, av_result, av_code, applied_for_connection, name_of_person_meet, relationship, remarks, get_location, resident, income, organization, occupation, company, agri_land, distance_from_branch, vehicle, gate_colour, wall_colour, person_image, poi_image, poa_image, signature', 'default', 'setOnEmpty' => true, 'value' => null),
            array('id, users_id, category, coustmer_name, coustmer_id, clint_name, alternate_no, installation_address, city, landmark, zone, product_type, state, pin_code, los_no, plan_name, activation_date, case_type, address_confirmation, subsriber_confirmation, av_result, av_code, applied_for_connection, name_of_person_meet, relationship, remarks, get_location, resident, income, organization, occupation, company, agri_land, distance_from_branch, vehicle, gate_colour, wall_colour, person_image, poi_image, poa_image, signature, applied_for_loan, taotal_family_mamber, earning_mamber, depandent, resident_detail, neighbor, resi_address, office_image, time_of_job, total_emp, net_sailry, enquiry_type', 'safe', 'on' => 'search'),
        );
    }
    public static function label($n = 1) {
		return Yii::t('app', 'Enquiry|Enquiries', $n);
	}

    public function search() {
        $criteria = new CDbCriteria;

        $criteria->compare('id', $this->id, true);

        if (!Yii::app()->user->isAdmin()) {

            $criteria->addCondition('t.users_id = :users_id');
            $criteria->params = array(':users_id' => Yii::app()->user->id);
        }
       $criteria->compare('users_id', $this->users_id);
		$criteria->compare('category', $this->category, true);
		$criteria->compare('coustmer_name', $this->coustmer_name, true);
		$criteria->compare('coustmer_id', $this->coustmer_id, true);
		$criteria->compare('clint_name', $this->clint_name, true);
		$criteria->compare('alternate_no', $this->alternate_no, true);
		$criteria->compare('installation_address', $this->installation_address, true);
		$criteria->compare('city', $this->city, true);
		$criteria->compare('landmark', $this->landmark, true);
		$criteria->compare('zone', $this->zone, true);
		$criteria->compare('product_type', $this->product_type, true);
		$criteria->compare('state', $this->state, true);
		$criteria->compare('pin_code', $this->pin_code, true);
		$criteria->compare('los_no', $this->los_no, true);
		$criteria->compare('plan_name', $this->plan_name, true);
		$criteria->compare('activation_date', $this->activation_date, true);
		$criteria->compare('case_type', $this->case_type, true);
		$criteria->compare('address_confirmation', $this->address_confirmation, true);
		$criteria->compare('subsriber_confirmation', $this->subsriber_confirmation, true);
		$criteria->compare('av_result', $this->av_result, true);
		$criteria->compare('av_code', $this->av_code, true);
		$criteria->compare('applied_for_connection', $this->applied_for_connection, true);
		$criteria->compare('name_of_person_meet', $this->name_of_person_meet, true);
		$criteria->compare('relationship', $this->relationship, true);
		$criteria->compare('remarks', $this->remarks, true);
		$criteria->compare('get_location', $this->get_location, true);
		$criteria->compare('resident', $this->resident, true);
		$criteria->compare('income', $this->income, true);
		$criteria->compare('organization', $this->organization, true);
		$criteria->compare('occupation', $this->occupation, true);
		$criteria->compare('company', $this->company, true);
		$criteria->compare('agri_land', $this->agri_land, true);
		$criteria->compare('distance_from_branch', $this->distance_from_branch);
		$criteria->compare('vehicle', $this->vehicle, true);
		$criteria->compare('gate_colour', $this->gate_colour, true);
		$criteria->compare('wall_colour', $this->wall_colour, true);
		$criteria->compare('person_image', $this->person_image, true);
		$criteria->compare('poi_image', $this->poi_image, true);
		$criteria->compare('poa_image', $this->poa_image, true);
		$criteria->compare('signature', $this->signature, true);
		$criteria->compare('applied_for_loan', $this->applied_for_loan);
		$criteria->compare('taotal_family_mamber', $this->taotal_family_mamber);
		$criteria->compare('earning_mamber', $this->earning_mamber, true);
		$criteria->compare('depandent', $this->depandent, true);
		$criteria->compare('resident_detail', $this->resident_detail, true);
		$criteria->compare('neighbor', $this->neighbor, true);
		$criteria->compare('resi_address', $this->resi_address, true);
		$criteria->compare('office_image', $this->office_image, true);
		$criteria->compare('time_of_job', $this->time_of_job, true);
		$criteria->compare('total_emp', $this->total_emp, true);
		$criteria->compare('net_sailry', $this->net_sailry, true);
		$criteria->compare('enquiry_type', $this->enquiry_type, true);

        return new CActiveDataProvider($this, array(
                    'criteria' => $criteria,
                ));
    }

}